#coding:utf-8
import serial

def read():
	ser = serial.Serial('COM2', 19200, timeout = 3)
	stu_id = ser.readline()
	ser.close()
	if len(stu_id) == 0:
		return None
	return stu_id

def write(msg):
	if msg[-1] != '\n':
		msg += '\n'
	ser = serial.Serial('COM2', 19200, timeout = 3)
	print msg
	ret = ser.write(msg)
	ser.close()
	return ret
